<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>系统主页</title>
</head>
<body style="background-color: burlywood">
<h1>学生管理</h1>
<p>
    <form action="/find" method="post">
        年纪：<select name="gradeid">
        <option value="-1">不限</option>
        <option value="1">一年级</option>
        <option value="2">二年级</option>
        <option value="3">三年级</option>
            </select>
        学号:<input type="text" name="studentno">
        姓名:<input type="text" name="stuname">
        <button type="submit">搜索</button>
    </form>
</p>

<input type="button" value="添加学生信息" onclick="javascript:location.href='/addpage'">

<table border="1" width="500">
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>年纪</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${pageinfo.list}" var="stu">
        <tr>
            <td>${stu.studentno}</td>
            <td>${stu.stuname}</td>
            <td>${stu.stuage}</td>
            <td>${stu.grade.gname}</td>
            <td>
                <input type="button" value="更新"  onclick="javascript:location.href='/update?stuid=${stu.studentid}'"></input>
                <input type="button" value="删除"  onclick="javascript:location.href='/delete?stuid=${stu.studentid}'"></input>
            </td>
        </tr>
    </c:forEach>

    <tr>
        <%--分页操作项--%>
        <td colspan="5">
            <c:if test="${gradeid==null}">
                <a href="/mainpage">首页</a>

                <a href="/mainpage?index=${pageinfo.prePage==0?1:pageinfo.prePage}">上一页</a>

                <a href="/mainpage?index=${pageinfo.nextPage==0?pageinfo.pages:pageinfo.nextPage}">下一页</a>

                <a href="/mainpage?index=${pageinfo.pages}">尾页</a>

            </c:if>
            <%-- ----------------------------------------------- --%>

            <c:if test="${gradeid!=null}">
                <a href="/find?gradeid=${gradeid}&studentno=${studentno}&stuname=${stuname}">首页</a>

                <a href="/find?index=${pageinfo.prePage==0?1:pageinfo.prePage}&gradeid=${gradeid}&studentno=${studentno}&stuname=${stuname}">上一页</a>

                <a href="/find?index=${pageinfo.nextPage==0?pageinfo.pages:pageinfo.nextPage}&gradeid=${gradeid}&studentno=${studentno}&stuname=${stuname}">下一页</a>

                <a href="/find?index=${pageinfo.pages}&gradeid=${gradeid}&studentno=${studentno}&stuname=${stuname}">尾页</a>

            </c:if>
            总页数：${pageinfo.pages}

            总条数：${pageinfo.total}

        </td>
    </tr>

</table>

</body>

</html>
